//
//  MY_getVendingListHttpApi.m
//  MiYuan_iOS
//
//  Created by zhangyongbing on 2018/5/11.
//  Copyright © 2018年 zhangyongbing. All rights reserved.
//

#import "MY_getVendingListHttpApi.h"
NSString *const MYURLPath_GetVendinList = @"/app/vender/page";
NSString *const MYURLPath_GetVendingMachine = @"/app/vender/%@/info";
NSString *const MYURLPath_GetUpdataVendingMachine = @"/app/vender/%@/update";
NSString *const MYURLPath_GetGoodclassification = @"/app/vender/goods/classification";
NSString *const MYURLPath_GetGoogList = @"/app/vender/%@/goods";

@implementation MY_getVendingListHttpApi

+ (void)myVendingMachineList_checkHomeNext:(NSString *)parameter
                                   PageNum:(NSString *)pagenum
                                  PageSize:(NSString *)pagesize
                         complationHandler:(OCJHttpResponseHander)handler {
    NSMutableDictionary *mDic = [NSMutableDictionary dictionary];
    [mDic setObject:parameter forKey:@"parameter"];
    [mDic setObject:pagenum forKey:@"current"];
    [mDic setObject:pagesize forKey:@"size"];
    
    [[OCJNetWorkCenter sharedCenter] ocj_POSTWithUrlPath:MYURLPath_GetVendinList parameters:mDic andLodingType:OCJHttpLoadingTypeNone completionHandler:^(OCJBaseResponceModel *responseModel) {
        handler(responseModel);
        
        if (![responseModel.ocjStr_code isEqualToString:@"0"]) {
            [SGInfoAlert showInfo:responseModel.ocjStr_message
                          bgColor:[[UIColor blackColor] CGColor]
                           inView:[[UIApplication sharedApplication] keyWindow]
                         vertical:0.7];
        }
    }];
}

+ (void)MYGet_VendingMachineDetailWithID:(NSString *)Id
                       completionHandler:(OCJHttpResponseHander)handler {
    
    NSString *strVendingMachine = [NSString stringWithFormat:MYURLPath_GetVendingMachine,Id];
    
    [[OCJNetWorkCenter sharedCenter] ocj_GETWithUrlPath:strVendingMachine parameters:nil andLodingType:OCJHttpLoadingTypeBeginAndEnd completionHandler:^(OCJBaseResponceModel *responseModel) {
        handler(responseModel);
        if (![responseModel.ocjStr_code isEqualToString:@"0"]) {
            [SGInfoAlert showInfo:responseModel.ocjStr_message
                          bgColor:[[UIColor blackColor] CGColor]
                           inView:[[UIApplication sharedApplication] keyWindow]
                         vertical:0.7];
        }
    }];
}


+ (void)myUpdataVendingMachineDetailWithID:(NSString *)Id
                                  PostData:(NSDictionary *)dic
                         complationHandler:(OCJHttpResponseHander)handler {
    NSMutableDictionary *mDic = [NSMutableDictionary dictionary];
    [mDic addEntriesFromDictionary:dic];
    
    NSString *strupdataurl = [NSString stringWithFormat:MYURLPath_GetUpdataVendingMachine,Id];
    
    [[OCJNetWorkCenter sharedCenter] ocj_POSTWithUrlPath:strupdataurl parameters:mDic andLodingType:OCJHttpLoadingTypeNone completionHandler:^(OCJBaseResponceModel *responseModel) {
        handler(responseModel);
        
        if (![responseModel.ocjStr_code isEqualToString:@"0"]) {
            [SGInfoAlert showInfo:responseModel.ocjStr_message
                          bgColor:[[UIColor blackColor] CGColor]
                           inView:[[UIApplication sharedApplication] keyWindow]
                         vertical:0.7];
        }
    }];
}

+ (void)myGetGoodclassificationWithcomplationHandler:(OCJHttpResponseHander)handler {
    NSMutableDictionary *mDic = [NSMutableDictionary dictionary];
    
    [[OCJNetWorkCenter sharedCenter] ocj_POSTWithUrlPath:MYURLPath_GetGoodclassification parameters:mDic andLodingType:OCJHttpLoadingTypeNone completionHandler:^(OCJBaseResponceModel *responseModel) {
        handler(responseModel);
        
        if (![responseModel.ocjStr_code isEqualToString:@"0"]) {
            [SGInfoAlert showInfo:responseModel.ocjStr_message
                          bgColor:[[UIColor blackColor] CGColor]
                           inView:[[UIApplication sharedApplication] keyWindow]
                         vertical:0.7];
        }
    }];
}

+ (void)mygoodsListWithMachineDetailWithID:(NSString *)Id
                          ClassificationId:(NSString *)ClassificationId
                                   PageNum:(NSString *)pagenum
                                  PageSize:(NSString *)pagesize
                         complationHandler:(OCJHttpResponseHander)handler {
    NSMutableDictionary *mDic = [NSMutableDictionary dictionary];
    [mDic setObject:ClassificationId forKey:@"classificationId"];
    [mDic setObject:pagenum forKey:@"current"];
    [mDic setObject:pagesize forKey:@"size"];
    
    NSString *strVendingMachine = [NSString stringWithFormat:MYURLPath_GetGoogList,Id];
    
    [[OCJNetWorkCenter sharedCenter] ocj_POSTWithUrlPath:strVendingMachine parameters:mDic andLodingType:OCJHttpLoadingTypeNone completionHandler:^(OCJBaseResponceModel *responseModel) {
        handler(responseModel);
        
        if (![responseModel.ocjStr_code isEqualToString:@"0"]) {
            [SGInfoAlert showInfo:responseModel.ocjStr_message
                          bgColor:[[UIColor blackColor] CGColor]
                           inView:[[UIApplication sharedApplication] keyWindow]
                         vertical:0.7];
        }
    }];
}

@end
